<?php 
	
?>
<table id="individual_table" class="table table-striped table-bordered table-hover">
	<thead>
		<tr>	
			<th><?php  echo translate_word_shop('bill_nr',$dictionary_app); ?></th>
			<th><?php  echo translate_word_shop('date',$dictionary_app); ?></th>
			<th><?php  echo translate_word_shop('person_type',$dictionary_app); ?></th>
			<th><?php  echo translate_word_shop('name',$dictionary_app); ?></th>
			<th><?php  echo translate_word_shop('status',$dictionary_app); ?></th>
			<th><?php  echo translate_word_shop('total',$dictionary_app); ?></th>
			<th><?php  echo translate_word_shop('Actions',$dictionary_app); ?></th>
		</tr>
	</thead>
	<tbody>
		<?php 
			$results=$shopObj->fetch_result("SELECT * FROM orders ");
			foreach($results as $key=>$value){
				$date = date('d/m/Y',$value['date']);
				$client= $shopObj->fetch_one("SELECT name,type FROM clients WHERE id='{$value['client_id']}'");
					
				if($client['type']==0){
					$type = translate_word_shop('individual_person',$dictionary_app);
				}else{
					$type = translate_word_shop('legal_person',$dictionary_app);
				}
				if($value['completed']==0){
					$sts= 'recieved';
				}else if($value['completed']==1){
					$sts= 'sent';
				}else{
					$sts='canceled';
				}
				$total = $shopObj->fetch_one("SELECT SUM(price) FROM order_items WHERE order_id='{$value['id']}'");
				echo "<tr>
						<td>{$value['id']}</td>
						<td>{$date}</td>
						<td>{$type}</td>
						<td>{$client['name']}</td>
						<td>{$sts}</td>
						<td>{$total[0]}</td>
						<td>
							<button class='btn btn-mini btn-success' href='javascript:void(0)' onclick='open_products({$value['id']})'>
								<i class='icon-pencil bigger-130'></i>
								".translate_word_shop('view_product',$dictionary_app)."
							</button>
							<button class='btn btn-mini btn-primary' href='javascript:void(0)' onclick='open_and_send({$value['id']})'>
								<i class='icon-print bigger-130'></i>
								".translate_word_shop('print_label',$dictionary_app)."
							</button>
							<button class='btn btn-mini btn-primary' href='javascript:void(0)' onclick='print_order({$value['id']})'>
								<i class='icon-print bigger-130'></i>
								".translate_word_shop('print_order',$dictionary_app)."
							</button>
						</td>
					  </tr>";
			}
		?>
	</tbody>
</table>
<div id="modal-order-products" class="modal hide fade" style='width:670px;' tabindex="-1">
	<div class="modal-header no-padding">
		<div class="table-header">
			<button type="button" class="close" data-dismiss="modal">&times;</button>
			<?php  echo translate_word_shop('order_products',$dictionary_app); ?>

		</div>
	</div>
	<div id='order_products'>
		<table id="order_prod_table" class="table table-striped table-bordered table-hover">
			<thead>
				<tr>
					<th><?php translate_word_shop('code',$dictionary_app); ?></th>
					<th><?php translate_word_shop('name',$dictionary_app); ?></th>
					<th><?php translate_word_shop('category',$dictionary_app); ?>  </th>
					<th><?php translate_word_shop('bar_code',$dictionary_app); ?></th>
					<th><?php translate_word_shop('quanity',$dictionary_app); ?></th>
					<th><?php translate_word_shop('price_buc',$dictionary_app); ?></th>
					<th><?php translate_word_shop('discount',$dictionary_app); ?></th>
					<th><?php translate_word_shop('total_price',$dictionary_app); ?></th>
				</tr>
			</thead>
			<tbody>

			</tbody>
		</table>
	
	</div>	
	<div class="modal-footer ">
		<button class="btn btn-small btn-primary" data-dismiss="modal" onclick='save_client();' ><?php  echo translate_word_shop('save',$dictionary_app); ?></button>
		<button class="btn btn-small btn-danger btn-primary" data-dismiss="modal"><?php  echo translate_word_shop('cancel',$dictionary_app); ?></button>
	</div>
</div>
<div id='print_send' style='display:none'>
	
</div>
